package com.sgb.net.api.demo;

import com.sgb.net.entity.BaseEntity;
import com.sgb.net.core.BaseNet;
import com.sgb.net.util.RxUtil;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.OkHttpClient;

/**
 * @author: 杨畔
 * @date: 2021/2/19 16:43
 * @Description: demo网络请求类
 */
public class DemoNet extends BaseNet {

    private final DemoService mService;

    private DemoNet() {
        mService = getService(DemoService.class, mBaseUrl);
    }

    private static class Single {
        private static final DemoNet instance = new DemoNet();
    }

    public static DemoNet getInstance() {
        return Single.instance;
    }

    @Override
    protected void handleBuilder(OkHttpClient.Builder builder) {

    }

    //-------------------------网络请求方法------------------------------

    /**
     * todo demo
     */
    public Observable<BaseEntity<Object>> common() {
        Map<String, Object> params = new HashMap<>();
        params.put("key", "value");
        return mService.common(params).compose(RxUtil.ioToMain());
    }
}
